﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HomeCareLibrary.Core.Dtos;

namespace HomeCareLibrary.Core.JsonObjects
{
    public class UserHomes
    {
        public int userId { get; set; }
        public List<Home> homes { get; set; }

        public UserHomes()
        { }

        public UserHomes(List<CTGetUserHomesDto> userHomes)
        {
            if (userHomes != null && userHomes.FirstOrDefault() != null)
            {
                userId = userHomes.FirstOrDefault().user_id;
                homes = new List<Home>();
                userHomes.ForEach(userHome =>
                    {
                        homes.Add(new Home(userHome.home_number, userHome.home_name, userHome.dwelling_type.ToString(), userHome.dwelling_code));
                    });
            }
            
        }
    }

    public class Home
    {
        public int homeNumber { get; set; }
        public string homeName { get; set; }
        public DwellingType dwelling { get; set; }

        public Home()
        {
            homeName = string.Empty;
        }

        public Home(int number, string name, string dwellingType, int dwellingCode)
        {
            homeNumber = number;
            homeName = name;
            dwelling = new DwellingType(dwellingType, dwellingCode);
        }
    }
}
